home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c / 538 < prev    next >
Text File  |  1996-08-06  |  3KB  |  70 lines

  1. Path: gabi-soft.fr!usenet
  2. From: kanze@gabi-soft.fr (J. Kanze)
  3. Newsgroups: comp.std.c
  4. Subject: Re: Multibyte and wide-character support
  5. Date: 07 Mar 1996 12:58:46 GMT
  6. Organization: GABI Software, Sarl.
  7. Message-ID: <KANZE.96Mar7135846@gabi.gabi-soft.fr>
  8. References: <4he9gg$m9l@pentagon.io.com>
  9. NNTP-Posting-Host: gabi.gabi-soft.fr
  10. In-reply-to: jamshid@io.com's message of 4 Mar 1996 02:26:56 -0600
  11.  
  12. In article <4he9gg$m9l@pentagon.io.com> jamshid@io.com (Jamshid Afshar)
  13. writes:
  14.  
  15. |> Is there an easy way to test if a multibyte string contains only
  16. |> singlebyte characters and thus can be passed to a function expecting a
  17. |> "regular" char*?  Is "if (strlen(mbs)==mblen(mbs))" a valid test and
  18. |> is there anything better?
  19.  
  20. "if ( strlen( mbs ) == mblen( mbs ) )" is definitly wrong.  mblen
  21. returns the number of byte in a (single) multi-byte character, not in
  22. the string.  About the only way I can think of doing this is by brute
  23. force, with a loop:
  24.  
  25.     bool                isMultibyte = false ;
  26.     while ( ! isMultibyte && *mbs != '\0' )
  27.     {
  28.         int                    n = mblen( mbs , -1 ) ;
  29.         isMultibyte = (n > 1) ;
  30.         mbs += n ;
  31.     }
  32.  
  33. |> Why aren't there wchar_t versions of functions like atoi() strtod()?
  34. |> Do they just have to be converted to multibyte strings, and do atoi(),
  35. |> etc. work with multibyte strings?
  36.  
  37. According to the standard: ``In other that the "C" locale, additional
  38. implementation-defined subject sequence forms may be accepted.''  In
  39. plain English: the implementor is allowed to support them, but not
  40. required to.
  41.  
  42. |> Btw, VC++4's docs say that if mbstowcs()'s wchar_t* destination
  43. |> argument is NULL then the function doesn't do a conversion of the
  44. |> multibyte string; it just returns the size needed to store the
  45. |> multibyte string.  Accepting a NULL first argument is not required by
  46. |> Standard C, is it?
  47.  
  48. No mention of it in my copy of the standard.
  49.  
  50. |> Also, the VC++4 docs seem to indicate fputws(), a
  51. |> wchar_t version of fputs(), is "ANSI" compatible.  Standard C doesn't
  52. |> actually specify any wide-character i/o functions, does it?
  53.  
  54. There not in the index, anyway.
  55.  
  56. The actual support for internationalization in C is very weak.  The only
  57. justification for this is that when the C standard was adopted, such
  58. support was totally lacking in all other languages; C was a definite
  59. inovater in this respect.
  60.  
  61. I believe that there are a number of additional functions which have
  62. been proposed for C9x.  Maybe one of the other readers can fill us in.
  63. You might also want to check out http://www.dmk.com/dmk/index.html,
  64. which is where all of the proposals are archived.
  65. -- 
  66. James Kanze           (+33) 88 14 49 00          email: kanze@gabi-soft.fr
  67. GABI Software, Sarl., 8 rue des Francs Bourgeois, 67000 Strasbourg, France
  68. Conseils, Θtudes et rΘalisations en logiciel orientΘ objet --
  69.               -- A la recherche d'une activitΘ dans une region francophone
  70.